package com.dong.containerEx.factoryBean;

import com.dong.containerEx.User;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * description
 *
 * @author Administrator 2021/08/31 10:59
 */
public class FactoryBeanTest {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:/bean.xml");
        User user = context.getBean(User.class);

        final User user2 = (User) context.getBean("myFactoryBean");
        FactoryBean myFactoryBean = (FactoryBean) context.getBean("&myFactoryBean");
        System.out.println(user);
        System.out.println(user2);
        System.out.println(myFactoryBean);

        System.out.println("--------");

        ApplicationContext context1 = new AnnotationConfigApplicationContext("com.dong.containerEx.factoryBean");
        User user1 = context1.getBean(User.class);
        System.out.println(user1);
    }

}
